package com.example.provider.service.impl;

import com.example.common.entity.Company;
import com.example.common.entity.Message;
import com.example.common.entity.WorkRoom;
import com.example.provider.dao.AdminDao;
import com.example.provider.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminDao adminDao;

    /**
     * 从数据库取出处于审批中的企业注册信息
     * @return
     */
    public List<Company> getCompany() {
        return adminDao.searchCompany();
    }

    /**
     * 通过企业注册申请
     * @param company
     * @return
     */
    public Message pass(Company company) {
        adminDao.updateCompanyStates(company);
        return new Message(800, "更新成功");
    }

    /**
     * 驳回企业注册申请
     * @param company
     * @return
     */
    public Message reject(Company company) {
        adminDao.updateCompanyStatesReject(company);
        return new Message(800, "驳回成功");
    }

    /**
     * 通过工作室注册申请
     * @return
     */
    public Message passWorkroom(WorkRoom workRoom) {
        adminDao.updateWorkroomStates(workRoom);
        return new Message(800, "更新成功");
    }

    /**
     * 驳回工作室注册申请
     * @param workRoom
     * @return
     */
    public Message rejectWorkroom(WorkRoom workRoom) {
        adminDao.updateWorkroomStatesReject(workRoom);
        return new Message(800, "驳回成功");
    }

    /**
     * 从数据库取出处于审批中的工作室注册信息
     * @return
     */
    public List<WorkRoom> getWorkroom() {
        return adminDao.searchWorkroom();
    }
}
